package com.bsdsma.visonManagementSystemapp.restcontroller;

import com.bsdsma.visonManagementSystemapp.dto.RoleDto;
import com.bsdsma.visonManagementSystemapp.enums.Role;
import com.bsdsma.visonManagementSystemapp.utils.ResultUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/api/enums")
public class EnumRestController {

    @GetMapping(value = "/roles")
    public Map<String, Object> listRoles(){
        Role[] roles = Role.values();
        List<RoleDto> retList = new ArrayList<>();
        for (Role item : roles) {
            RoleDto dto = new RoleDto();
            dto.setName(item.name());
            dto.setValue(item.getValue());
            dto.setDesc(item.getDesc());
            retList.add(dto);
        }
        return ResultUtils.ok(retList);
    }

}
